﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Business.Models
{
    public class PhuHuynh
    {
        [Key]
        public int IdPhuHuynh { get; set; }
        public string TenPhuHuynh { get; set; }
        public string Email { get; set; }
        public string SoDienThoai { get; set; }
        public DateTime NgayTao { get; set; }
        public bool HoatDong { get; set; }
        //public int TruongHoc { get; set; }
        public virtual TruongHoc TruongHoc { get; set; }
    }

    public class PhuHuynhConfiguration : EntityTypeConfiguration<PhuHuynh>
    {

        public PhuHuynhConfiguration()
            : base()
        {

            HasKey(d => d.IdPhuHuynh);
            Property(d => d.IdPhuHuynh).
                HasColumnName("IdPhuHuynh").
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
                IsRequired();

            Property(d => d.TenPhuHuynh).
                HasColumnName("TenPhuHuynh").
                IsRequired();

            Property(d => d.Email).
                HasColumnName("Email").
                IsRequired();

            Property(d => d.SoDienThoai).
                HasColumnName("SoDienThoai").
                IsRequired();

            Property(d => d.NgayTao).
                HasColumnName("NgayTao").
                IsRequired();

            Property(d => d.HoatDong).
                HasColumnName("HoatDong").
                IsRequired();

            HasRequired(x => x.TruongHoc).
            WithMany().
                Map(x => x.MapKey("TruongHoc"));
            
            ToTable("PhuHuynh", "dbo");
        }

    }
}